package com.imodia.checkoo.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hsq.commons.util.db.GenericIbatisDao;
import com.hsq.commons.util.db.PageBean;
import com.hsq.commons.util.db.PageResult;
import com.hsq.commons.util.db.SqlParam;
import com.hsq.commons.util.db.annotation.SqlSpace;
import com.imodia.checkoo.bean.CmsAttachmentSourceBean;
import com.imodia.checkoo.service.CmsAttachmentSourceService;

@SqlSpace(spaceName="cmsattachmentsource")
@Service("cmsAttachmentSourceService")
public class CmsAttachmentSourceServiceImpl extends GenericIbatisDao<CmsAttachmentSourceBean, Integer> implements CmsAttachmentSourceService {
	
	public List<CmsAttachmentSourceBean> listByArticleId(int articleId){
		SqlParam sql = new SqlParam();
		sql.andEqualTo("article_id", String.valueOf(articleId));
		return super.list(sql);
	}
	
	public PageResult<CmsAttachmentSourceBean> queryPage(CmsAttachmentSourceBean attachment,PageBean page){
		SqlParam param = new SqlParam();
		if(attachment.getArticleId()>0){
			param.andEqualTo("article_id", String.valueOf(attachment.getArticleId()));
		}
		PageResult<CmsAttachmentSourceBean> attachmentPage = this.page(param,page);
		return attachmentPage;
	}
	

}
